package com.vm.osm.business.dto.req.logic_equ;

import com.google.common.base.MoreObjects;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * 更新逻辑设备请求
 *
 * @author Xuerong Xue
 */
@Data
public class UpdateLogicEquReq implements Serializable {
    @ApiModelProperty(value = "逻辑设备Id", required = true)
    @NotEmpty(message = "逻辑设备Id不能为空")
    private String id;

    @ApiModelProperty(value = "逻辑节点Id", required = true)
    @NotEmpty(message = "逻辑节点Id不能为空")
    private String logic_no_id;

    @ApiModelProperty(value = "设备编码")
    private String equ_code;

    @ApiModelProperty(value = "设备类型（1：通用设备类型，2：专业设备类型）", required = true)
    @NotNull(message = "设备类型不能为空")
    private Byte equ_type;

    @ApiModelProperty(value = "设备类型Id", required = true)
    @NotNull(message = "设备类型Id不能为空")
    private String equ_type_id;

    @ApiModelProperty(value = "归属类型（1：自有设备，2：客户）", required = true)
    @NotNull(message = "设备归属不能为空")
    private Byte belong_type;

    @ApiModelProperty("设备归属者Id")
    private String belonger_id;

    @ApiModelProperty("设备属性集合")
    private List<EquAttrField> common_attr_list;

    @ApiModelProperty("自定义属性列表")
    private List<DiyAttrField> diy_field_list;

    @ApiModelProperty("配件列表")
    private List<EquPart> equ_part_list;

    @ApiModelProperty(value = "企业Id", hidden = true)
    private String enterprise_id;

    @ApiModelProperty(value = "会话Id", hidden = true)
    private String session_id;

    @Data
    @ApiModel(value = "EquAttrField", description = "设备属性")
    public static class EquAttrField implements Serializable {
        @ApiModelProperty("字段key")
        private String field_key;
        @ApiModelProperty("字段value")
        private String field_value;

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .add("field_key", field_key)
                    .add("field_value", field_value)
                    .toString();
        }
    }

    @Data
    @ApiModel(value = "DiyAttrField", description = "自定义属性")
    public static class DiyAttrField implements Serializable {
        @ApiModelProperty("diy字段Id")
        private String id;
        @ApiModelProperty("字段值")
        private String field_value;
        @ApiModelProperty("字段标题")
        private String field_title;

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .add("id", id)
                    .add("field_value", field_value)
                    .add("field_title", field_title)
                    .toString();
        }
    }

    @Data
    @ApiModel(value = "EquPart", description = "设备配件信息")
    public static class EquPart implements Serializable {
        @ApiModelProperty("配件Id，若为关联该字段必填，否则置空")
        private String id;
        @ApiModelProperty("品牌")
        private String brand;
        @ApiModelProperty("配件类型编号")
        private String equ_part_type_id;
        @ApiModelProperty("生产厂家")
        private String manufactor_id;
        @ApiModelProperty("计量单位")
        private String measure_unit;
        @ApiModelProperty("型号")
        private String model;
        @ApiModelProperty("原值")
        private String original_value;
        @ApiModelProperty("pn")
        private String pn;
        @ApiModelProperty("购买日期")
        private Integer purchase_date;
        @ApiModelProperty("sn")
        private String sn;
        @ApiModelProperty("规格")
        private String spec;
        @ApiModelProperty("规格")
        private String supplier_id;
        @ApiModelProperty("质保")
        private Integer warranty_date;

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                    .add("id", id)
                    .add("brand", brand)
                    .add("equ_part_type_id", equ_part_type_id)
                    .add("manufactor_id", manufactor_id)
                    .add("measure_unit", measure_unit)
                    .add("model", model)
                    .add("original_value", original_value)
                    .add("pn", pn)
                    .add("purchase_date", purchase_date)
                    .add("sn", sn)
                    .add("spec", spec)
                    .add("supplier_id", supplier_id)
                    .add("warranty_date", warranty_date)
                    .toString();
        }
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("id", id)
                .add("logic_no_id", logic_no_id)
                .add("equ_code", equ_code)
                .add("equ_type", equ_type)
                .add("equ_type_id", equ_type_id)
                .add("belong_type", belong_type)
                .add("belonger_id", belonger_id)
                .add("common_attr_list", null == common_attr_list ? null : Arrays.toString(common_attr_list.toArray()))
                .add("diy_field_list", null == diy_field_list ? null : Arrays.toString(diy_field_list.toArray()))
                .add("equ_part_list", null == equ_part_list ? null : Arrays.toString(equ_part_list.toArray()))
                .toString();
    }
}
